﻿
@model IPagedList<Entidades.Seguridad.Perfil>
@using MvcPaging;
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<link href="../../Content/themes/bootstrap.extra.table.css" rel="stylesheet" />
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<h1>Gestion <small>de Perfiles</small></h1>

    @if (ViewBag.PermisoCrear)
    {
        <p> @Html.ActionLink("Crear Nuevo Perfil", "Create2", null, new { @class = "btn" }) </p>
    }
    else
    {
        <p> <input type="submit" class="btn disabled" value="Crear Nuevo Perfil" /> </p>
    }
    
@using (Html.BeginForm("Search", "Perfiles", FormMethod.Get))
{
 <div class="searchBox">
     <div class=clearfix>
        Seleccionar Grupo:
        @Html.DropDownList("Grupo", ViewBag.IdGrupo as SelectList, new { id = "Grupo" })
        @Html.ValidationMessage("CustomError", "*")
        
        <br>
        <br>
        Seleccionar Formulario:         
        @Html.DropDownList("Formulario", ViewBag.IdFormulario as SelectList, new { id = "Formulario" })
        @Html.ValidationMessage("CustomError", "*")
         
        <br>
        <br>
        Seleccionar Permiso:
        @Html.DropDownList("Permiso", ViewBag.IdPermiso as SelectList, new { id = "Permiso" })
        @Html.ValidationMessage("CustomError", "*")
         
        <br>
        <br>
         <input type="submit" value="Filtrar" class="btn small" />
     </div>
     
 </div>
}

<div class="pagingContainer">
    @Html.Pager(Model.PageSize, Model.PageNumber, Model.TotalItemCount)
</div>
 
        <table class="zebra-striped">
        <thead>
            <th>
                Grupo
            </th>
            <th>
                Formulario
            </th>
            <th>
                Permiso
            </th>
            <th>
                Acciones
            </th>
        </thead>

        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Grupo.IdGrupo)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Formulario.Nombre)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Permiso.Nombre)
                </td>
                <td>
                    
                    @if (ViewBag.PermisoDelete)
                    {
                           @Html.ActionLink("Eliminar", "Delete", new
                      {
                          idgrupo = item.Grupo.IdGrupo,
                          idform = item.Formulario.IdFormulario,
                          idpermiso = item.Permiso.IdPermiso
                      }, new { @class = "btn" })
                    }
                    else
                    {
                        <input type="submit" class="btn disabled" value="Eliminar" />
                    }
                   
                </td>
            </tr>
        }

        </table>